
<%@ page import="java.util.List" %>
<%@ page import="domain.model.invite.Invite" %>
<%@ page import="domain.model.group.Group" %>
<%@ page import="domain.model.group.mapper.GroupInputMapper" %>
<%@ page import="domain.model.user.User" %>   
<%@ page import="domain.model.user.IUser" %>  

<h2> ${title} </h2>
<p>View Invites Information below: </p>

<script type="text/javascript">

// Hide and display advanced search
$(document).ready(function() {
	//$("#adv_search_container").hide();
	});
	function showTeam(group)
	{
		$("#group_box_" + group).slideToggle(400);
		return false;
	}
</script> 

<div id="queryContents">

 		<%
			List<Invite> invites = (List<Invite>)request.getAttribute("inviteList");
			
			if(invites.isEmpty())
			{
				%>
				<h2>You have no invites</h2>
				<%
			}
		%>
		
		<table border="1" style="border-collapse: collapse;">
			<tr>
				<th>Group Name</th>
				<th>Accept Invite</th>
				<th>Decline Invite</th>
			</tr>
		   <%
				
				//List<User> users = (List<User>)request.getAttribute("users");
				for(Invite invite: invites)
				{
					Group g = GroupInputMapper.find(invite.getGroup().getId());
					List<IUser> users = g.getMemberList();
			%>
				<tr>
			 		<td>
			 			<a href="" onclick="showTeam(<%=g.getId()%>); return false;" ><%=g.getName()%></a>
						<div id="group_box_<%=g.getId()%>" style="display: none; text-align:left;">
							<br />
							<% for(IUser u: users)
							   {
							%>
								- <%=u.getFirstName()%> <%=u.getLastName()%><br />
							<% 	
							   }
							%>
						</div>
					</td>
					<td><a href="acceptinvite&accepted=true&inviteid=<%=invite.getId()%>&inviteversion=<%=invite.getVersion()%>"><button>Accept</button> </a> </td>
					<td><a href="acceptinvite&accepted=false&inviteid=<%=invite.getId()%>&inviteversion=<%=invite.getVersion()%>"><button>Decline</button> </a> </td>
				</tr>
			<%
				}
			%>
		</table>
</div> <!--closing queryContents -->